package adv42;

/**
 * @author oldliu
 * @since 1.0
 */
public class Depositer extends Thread {
    private final Account acount;

    public Depositer(String name, Account ac) {
        super(name);
        this.acount = ac;
    }

    @Override
    public void run() {
        while (true) {
            try {
                sleep(1600);
                synchronized (acount) {
                    acount.deposit(4500);
                    System.out.println("老杨存钱4500，现在余额是"+ acount.getMoney()+"元");
                    acount.notifyAll();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
